import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class loadPanelSpike {
	public static void main(String[] args) {
		JOptionPane loader = new JOptionPane();
		int toLoad = loader.showConfirmDialog(null, "Would you like to load your file?", "Would you like to load your file?", JOptionPane.YES_NO_OPTION);
		
		if(toLoad == 0) {
			JOptionPane theFile = new JOptionPane();
			String fileToLoad = theFile.showInputDialog(null, "What is your file's name?");
			fileToLoad = fileToLoad.toLowerCase();
			int peepCount = 0;
			try {
				Scanner peepCounter = new Scanner(new File("gameFiles.txt"));
				int counter = 0;
				while(peepCounter.hasNext()) {
					if(counter < 5) {
						counter++;
					}
					else {
						counter = 0;
						peepCount++;
					}
					String rar = fileLoader.next();
				}
			}
			catch(FileNotFoundException e) {}
			
			Player[] playerStuff = new Player[peepCount];
			
			try {
				Scanner fileLoader = new Scanner(new File("gameFiles.txt"));
				int position = 0;
				int counter = 0;
				while(fileLoader.hasNext()) {
					if(counter == 0) {
						playerStuff[position].setFName(fileLoader.next());
						counter++;
					}
					else if(counter == 1) {
						playerStuff[position].setLName(fileLoader.next());
						counter++;
					}
					else if(counter == 2) {
						playerStuff[position].setWins(fileLoader.nextInt());
						counter++;
					}
					else if(counter == 3) {
						playerStuff[position].setLosses(fileLoader.nextInt());
						counter++;
					}
					else if(counter == 4) {
						playerStuff[position].setBank(fileLoader.nextInt());
						counter++;
					}
					else if(counter == 5) {
						counter = 0;
						position++;
						String blah = fileLoader.next();
					}
				}
			}
			catch(FileNotFoundException e) {}
		}
	}
}